<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="d1">
    <input type="text" placeholder="请输入一个1-100的整数" v-model="num">
    <input type="button" value="猜一猜" @click="f()">
    <h1>{{result}}</h1>
</div>
<script src="js/vue.min.js"></script>
<script>
    let x = parseInt(Math.random()*100)+1;
    let times=0;
    let v = new Vue({
        el:"#d1",
        data:{
         num:"",
         result:""
        },
        methods:{
            f(){
                times++;
                if (v.num>x){
                    v.result="猜大了";
                }else if (v.num<x){
                    v.result="猜小了";
                }else if(v.num==x){
                    v.result="恭喜你第"+times+"次猜对了"
                }
            }
        }
    })
</script>

</body>
</html>